#include <allegro.h>
#include "CSprite.h"

#define WIN_W 640
#define WIN_H 480

void init();
void deinit();

int main() {
	init();
	BITMAP *buffer;
	buffer = create_bitmap(WIN_W, WIN_H);
	ASSERT(*buffer != NULL);

	CSprite hero;
    hero.LoadBitmap("res_img/hero.bmp");
    hero.SetTransBitmap(66, 255, 45);
	
	while (!key[KEY_ESC]) {
		/* put your code here */	
		hero.Blit(buffer, 0, 0, 0, 0);
		hero.BlitSprite(buffer, 100, 0);
		
		blit(buffer, screen, 0, 0, 0, 0, WIN_W, WIN_H);
		clear_bitmap(buffer);
	}

	deinit();
	return 0;
}
END_OF_MAIN()

void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, WIN_W, WIN_H, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}

void deinit() {
	clear_keybuf();
	/* add other deinitializations here */
	release_screen();
}
